<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body>
    <header class="aui-bar aui-bar-nav">
        <a href="" class="aui-pull-left"><span class="aui-iconfont aui-icon-left" onclick="api.closeWin()"></span></a>
        <div class="aui-title">绑定手机号</div>
    </header>

    <div class="aui-content aui-margin-t-15">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <label>手机号：<input placeholder="请输入11位手机号" id="newPhoneNumber"></label>
                </div>
            </li>

            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <label>校验码：
                    <input id="Verification_code" placeholder="请输入验证码"style="width:100px" >
                    </label>
                    <div class="aui-btn aui-btn-warning aui-pull-right" onclick="change()">换一张？</div>
                </div>
            </li>
        </ul>
    </div>

    <p>
        <div class="aui-btn aui-btn-block" onclick="openSuccess()">下一步</div>
    </p>
</body>
<script type="text/javascript">
    apiready = function() {
        window.openSuccess = function() {
          var newPhoneNumber = $api.byId('newPhoneNumber');
          var Verification_code = $api.byId('Verification_code');
          newPhoneNumberValue = newPhoneNumber.value;
          var token='';
          var body={
            token:$api.getStorage('token'),
            newPhoneNumber: newPhoneNumberValue
          }
          api.ajax({
              url: 'http://www.mk517.com/webApi/updateBindPhone_2.php',
              method: 'post',
              dataType:'json',
              "headers":{"Content-Type":"application/json"},
              data: {
                body:body
              }
          }, function(ret, err) {
              if (ret) {
                if(ret.state==true){
                  api.alert({
                      msg: '绑定成功',
                  }, function(ret, err){
                      // if( ret ){
                      //      alert( JSON.stringify( ret ) );
                      // }else{
                      //      alert( JSON.stringify( err ) );
                      // }
                  });

                }
                  // alert(JSON.stringify(ret));
              } else {
                  // alert(JSON.stringify(err));
              }
          });

        }


    }

</script>

</html>
